using System;
using System.Collections; 

namespace FilmekAdatbazis
{
	/// <summary>
	/// Summary description for Utils.
	/// </summary>
	public class Utils
	{
		public Utils()
		{
			//
			// TODO: Add constructor logic here
			//
		}
		public static void ComboEpito(System.Windows.Forms.ComboBox cb, System.Data.SqlClient.SqlDataReader DtReadcombo, ref ArrayList aKOD)
		{
			
			while(DtReadcombo.Read())
			{
				cb.Items.Add(DtReadcombo[1].ToString());    
				aKOD.Add(DtReadcombo[0].ToString());
			}
			DtReadcombo.Close();

		}

		public static int ComboSelectedItemID(System.Windows.Forms.ComboBox cb, ArrayList alID)
		{
			int i = cb.SelectedIndex;
			if (i >=0 )
			{
				int ID = Convert.ToInt32(alID[i]);
				return ID;
			}
			else
				return -1;
		}
		public static void SetComboToID(int keresettID, System.Windows.Forms.ComboBox cb, ArrayList alID)
		{	
			System.Collections.IEnumerator alEnum = alID.GetEnumerator();
			int i = 0;
			bool talalt = false;
			while ( (alEnum.MoveNext ()) && ( !talalt)) 
			{
				if ( Convert.ToInt32(alEnum.Current.ToString()) == keresettID)
				{
						cb.SelectedIndex = i;
						talalt = true;
				}
				i++;
			}
		}
	
		
	}
}
